﻿<Serializable>
Public NotInheritable Class DbfDataTable
    Inherits System.Data.DataTable
    Implements IDisposable
    '
    Private MY_DBFFile As Core.DbfFile = Nothing
    Public Sub New()
        MyBase.New()
        Me.Locale = System.Globalization.CultureInfo.InvariantCulture
    End Sub
    Public Sub New(ByVal pathfile As String, Optional ByVal version As DbfVersion = DbfVersion.dBaseIV)
        Me.New()
        '
        MY_DBFFile = Core.DbfFile.Get(pathfile, System.Text.Encoding.ASCII, version)
        If MY_DBFFile Is Nothing Then Throw New Exception("DBF file is not initialized or does not exist!") : Return
        '
        For X As Int32 = 0 To MY_DBFFile.Columns.Count - 1
            If X = 0 Then Continue For ' we dont want to include the first column in the DBF table
            Using NewDataColumn As New Data.DataColumn
                Me.Columns.Add(MY_DBFFile.Columns(X))
            End Using
        Next X
    End Sub
End Class
